home *** CD-ROM | disk | FTP | other *** search
-
- // SKEL-BAL v1.0
-
- // (BBS ADD/LIST DOOR)
-
- //**********************
- //***** Includes *****
- //**********************
-
- #include <proto/all.h>
- #include <stdio.h>
-
- #include <stdarg.h>
- #include <string.h>
- #include <tempest/headers.h>
-
- //********************************
- //***** Structures/Defines *****
- //********************************
-
- struct MyMessage
- {
- struct Message Msg; // for Exec message routines
- ULONG Command; // Command to be executed.
-
- char *text1,
- *text2,
- *text3;
- int Value1,
- Value2;
- ULONG LongValue;
- LONGBITS Flags;
- int carrier;
- struct User *User;
- struct SystemData *SystemData;
- struct NodeData *NodeData;
- struct Today *Today;
- };
-
- struct BBSLIST
- {
- char Name[21],
- Number[21],
- Location[21],
- Sysop[21],
- Groups[21],
- Support[21],
- Nodes[3],
- Megs[5],
- Baud[6];
- };
-
- struct BBSLIST BL;
- struct User *User;
- struct MsgPort *MyPort = NULL;
- struct MyMessage *msg;
- struct MyMessage send;
-
- int DoorStart(TEXT *);
- int DOORIO(VOID);
- VOID CloseStuff(VOID);
-
- VOID input(TEXT *,int);
- VOID LineInput(TEXT *,TEXT *,int);
- VOID pl(TEXT *,...);
-
- char MyName[60],st[60];
- char string1[255],string2[255];
-
- //******************
- //***** Main *****
- //******************
-
- VOID main(int argc,char *argv[])
- {
- int Test = 1;
- if(!DoorStart(argv[1])) { PutStr("Tempest Door!\n"); exit(0); }
- while(Test)
- {
- pl("\f[DSKEL-BAL v3.15] BBS Add/List Door By Michael Bockert [05-24-94]\r\n");
- pl("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n");
- pl("[A] -- Add a number to database.\r\n");
- pl("[D] -- Delete a number from database.\r\n");
- pl("[E] -- Edit a number in database.\r\n");
- pl("[L] -- List Numbers in the database.\r\n");
- pl("[S] -- Search for a number in database.\r\n");
- pl("[Q] -- Quit back to the BBS.\r\n\r\n");
- pl("Select [A,D,E,L,S,Q] : ");
- input(string1,1);
- if((string1[0] == 'q') || (string1[0] == 'Q')) Test = 0;
- if((string1[0] == 'a') || (string1[0] == 'A')) New();
- if((string1[0] == 'l') || (string1[0] == 'L')) List();
- if((string1[0] == 'e') || (string1[0] == 'E')) Edit();
- }
- CloseStuff();
- }
-
- //*************************
- //***** List Entrys *****
- //*************************
-
- List(VOID)
- {
- int fd,stat,lines;
- lines=0;
- fd=Open("DOORS:DSKEL-BAL.Data",MODE_OLDFILE);
- if(fd==0) { pl("Error reading Doors:DSKEL-BAL.Data\n\r"); return(0); }
-
- pl("\f");
- ReadRecord:
- stat=Read(fd,(char *)&BL,sizeof(struct BBSLIST));
- if(stat<=0)
- {
- pl("Hit any key:");
- hotkey(string1);
- Close(fd);
- return(0);
- }
- pl(" [Name] %-20s [ %s Nodes] [Sysop] %-20s\r\n",
- BL.Name,BL.Nodes,BL.Sysop);
- pl(" [Phone] %-20s [%4s Megs] [Groups] %-20s\r\n",
- BL.Number,BL.Megs,BL.Groups);
- pl("[Located] %-20s [%5s Baud] [Support] %-20s\r\n\r\n",
- BL.Location,BL.Baud,BL.Support);
- lines+=4;
- if(lines+4>User->Length)
- {
- pl("Hit any key:");
- hotkey(string1);
- lines=0;
- pl("\r\n\r\n");
- }
- goto ReadRecord;
- }
-
- //***************************
- //***** Add New Entry *****
- //***************************
-
- New(VOID)
- {
- int fd;
- pl("\f [--------------------]\r\n");
- pl(" BBS Name: ");
- input(BL.Name,20);
- pl("\r\n [--------------------]\r\n");
- pl(" Phone Number: ");
- input(BL.Number,20);
- pl("\r\n [--------------------]\r\n");
- pl(" Groups: ");
- input(BL.Groups,20);
- pl("\r\n [--------------------]\r\n");
- pl(" Location: ");
- input(BL.Location,20);
- pl("\r\n [--------------------]\r\n");
- pl(" Sysop: ");
- input(BL.Sysop,20);
- pl("\r\n [--------------------]\r\n");
- pl(" Formats Supported: ");
- input(BL.Support,20);
- pl("\r\n [-]\r\n");
- pl(" # Nodes: ");
- input(BL.Nodes,1);
- pl("\r\n [----]\r\n");
- pl(" Megs of Storage: ");
- input(BL.Megs,4);
- pl("\r\n [-----]\r\n");
- pl(" Max Buad Rate: ");
- input(BL.Baud,5);
- pl("\r\nSave to database [y/n] ");
- input(string1,1);
- if((string1[0] =='n') || (string1[0] == 'N')) return(0);
-
- //***********************************
- //***** Write DSKEL-BAL.Data ******
- //***********************************
-
- fd=Open("DOORS:DSKEL-BAL.Data",MODE_OLDFILE);
- if(fd==0)
- {
- fd=Open("DOORS:DSKEL-BAL.Data",MODE_NEWFILE);
- if(fd==0)
- {
- pl("Error writing Doors:DSKEL-BAL.Data!\r\n");
- CloseStuff();
- }
- }
- else
- Seek(fd,0,OFFSET_END);
- Write(fd,(char *)&BL ,sizeof(struct BBSLIST));
- Close(fd);
- return(0);
- }
-
- //*************************
- //***** Edit Entrys *****
- //*************************
-
- Edit(VOID)
- {
- char string[255];
- int fd,Slot;
- long Position;
- pl("Edit which Entry?: ");
- input(string,3);
- Slot = atoi(string);
- fd=Open("DOORS:DSKEL-BAL.Data",MODE_OLDFILE);
- if(fd==0)
- {
- pl("Error reading Doors:DSKEL-BAL.Data\n\r"); return(0);
- }
- Slot--;
- Position = Slot * sizeof(struct BBSLIST);
- Seek(fd,Position,0);
- Read(fd,(char *)&BL,sizeof(struct BBSLIST));
- Close(fd);
- pl("\f [--------------------]\r\n");
- pl(" BBS Name: ");
- LineInput(BL.Name,string,20);
- strcpy(BL.Name,string);
- pl("\r\n [--------------------]\r\n");
- pl(" Phone Number: ");
- LineInput(BL.Number,string,20);
- strcpy(BL.Number,string);
- pl("\r\n [--------------------]\r\n");
- pl(" Groups: ");
- LineInput(BL.Groups,string,20);
- strcpy(BL.Groups,string);
- pl("\r\n [--------------------]\r\n");
- pl(" Location: ");
- LineInput(BL.Location,string,20);
- strcpy(BL.Location,string);
- pl("\r\n [--------------------]\r\n");
- pl(" Sysop: ");
- LineInput(BL.Sysop,string,20);
- strcpy(BL.Sysop,string);
- pl("\r\n [--------------------]\r\n");
- pl(" Formats Supported: ");
- LineInput(BL.Support,string,20);
- strcpy(BL.Support,string);
- pl("\r\n [-]\r\n");
- pl(" # Nodes: ");
- LineInput(BL.Nodes,string,1);
- strcpy(BL.Nodes,string);
- pl("\r\n [----]\r\n");
- pl(" Megs of Storage: ");
- LineInput(BL.Megs,string,4);
- strcpy(BL.Megs,string);
- pl("\r\n [-----]\r\n");
- pl(" Max Buad Rate: ");
- LineInput(BL.Baud,string,5);
- strcpy(BL.Baud,string);
- pl("\r\nSave changes to database [y/n] ");
- input(string1,1);
- if((string1[0] =='n') || (string1[0] == 'N')) return(0);
-
- //***********************************
- //***** Write DSKEL-BAL.Data ******
- //***********************************
-
- fd=Open("DOORS:DSKEL-BAL.Data",MODE_OLDFILE);
- if(fd==0)
- pl("Error writing Doors:DSKEL-BAL.Data!\r\n");
- else
- Seek(fd,Position,0);
- Write(fd,(char *)&BL ,sizeof(struct BBSLIST));
- Close(fd);
- return(0);
- }
-
-
-
-
-
-
-
-
-
- //************************
- //***** Door Start ***** // MUST BE INCLUDED IN ALL DOORS!
- //************************
-
- int DoorStart(TEXT *node)
- {
- struct MsgPort *HisPort;
- send.carrier=0;
- sprintf(st,"%s:TEMPEST_DOOR",node);
- HisPort = FindPort(st);
- if(HisPort==NULL) return (FALSE);
- sprintf(MyName,"%s:DOOR_PORT",node);
- MyPort = CreatePort(MyName,0L);
- if(MyPort==NULL)
- {
- PutStr("Cant open port");
- return(int)FALSE;
- }
- DOORIO();
- User=*&send.User;
- return (int)TRUE;
- }
-
- //********************
- //***** DoorIO ***** // MUST BE INCLUDED IN ALL DOORS!
- //********************
-
- int DOORIO(VOID)
- {
- struct MsgPort *HisPort;
- if(send.carrier) return(0);
- HisPort = FindPort(st);
- if(HisPort!=NULL)
- {
- send.Msg.mn_Node.ln_Type = NT_MESSAGE;
- send.Msg.mn_Length = sizeof(send);
- send.Msg.mn_ReplyPort = MyPort;
- send.carrier=0;
- PutMsg((struct MsgPort *)HisPort,(struct Message *)&send);
- Wait(1 << MyPort->mp_SigBit);
- GetMsg(MyPort);
- if(send.carrier) CloseStuff();
- return(1);
- }
- return(0);
- }
-
- //*************************
- //***** Close Stuff ***** // MUST BE INCLUDED IN ALL DOORS!
- //*************************
-
- VOID CloseStuff(VOID)
- {
- send.Command=999;
- DOORIO();
- while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
- if(MyPort) DeletePort(MyPort);
- exit(0);
- }
-
- //*********************
- //***** Hot Key ***** // Command 16
- //*********************
-
- int hotkey(TEXT *character)
- {
- send.Command=16;
- send.text1=character;
- DOORIO();
- return((int)character[0]);
- }
-
- //*******************
- //***** Input ***** // Command 20
- //*******************
-
- VOID input(TEXT *mstring,int len)
- {
- send.Command=20;
- send.Value1=len;
- send.text1 =mstring;
- DOORIO();
- }
-
- //************************
- //***** Line Input ***** // Command 22
- //************************
-
- VOID LineInput(TEXT *ostring,TEXT *mstring,int len)
- {
- send.Command=22;
- send.Value1=len;
- send.text1=mstring;
- send.text2=ostring;
- DOORIO();
- }
-
- //*****************************
- //***** PL (Print Line) ***** // Command 1 with a twist
- //*****************************
-
- VOID pl(TEXT *fmt,...)
- {
- va_list args;
- char s[255];
- va_start(args,fmt);
- vsprintf(s,fmt,args);
- va_end(args);
- send.Command=1;
- send.text1=&s[0];
- DOORIO();
- }
-